<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>修改密码</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand" />
    <link rel="shortcut icon" href="/favicon.ico" type="/image/x-icon">
    <link rel="apple-touch-icon-precomposed" href="">
    <link rel="stylesheet" href="../source/src/css/main.css"/>
    <script src="../source/src/js/common.js"></script>

</head>
<body>
    <!-- 修改密码 -->
    <div class="login pubForm-box">
        <div class="hd">
            <div class="logo">
                <img src="../source/img/public/logo.png" alt="logo.png">
            </div>

            <h1>修改密码</h1>
        </div>

        <div class="bd">
            <ul>
                <li class="pwd-box clearfix">

                    <div class="v fl">

                    </div>
                </li>
                <li class="form-li clearfix">
                    <input type="text" name="" id="password" class="inp" placeholder="请输入新密码"/>
                </li>
                <li class="error-tip animated">

                </li>
            </ul>
            <div class="btn-box">
                <input type="submit" value="确认修改" id="update-btn" class="update-btn">
            </div>
        </div>
    </div>
    <!-- /登录 -->

    <script src="../source/plugin/zepto.min.js"></script>
    <script src="../source/src/js/common.js"></script>
    <script>
        function checkLogin(pwd){
            var  pwd=pwd,
                 errorTxt='';
            if ($.trim(pwd)=="") {
                errorTxt="请输入密码！";
            }
            return errorTxt !="" ? errorTxt : true;
        }


        $(function(){
            $('#update-btn').on('click',function(){
                var pwd=$('#password').val() || "",
                    errorMsg = checkLogin(pwd);

                if(errorMsg===true){
                    $('.error-tip').html("").hide();
                    var json = {
                        "username":decodeURIComponent(getCookie('username')),
                        "pwd":pwd,
                        "account":user.account,
                        "key":user.key,
                    };

                    console.log(json)
                    $.ajax({
                        url:apiUrl+'/UpdLogin',
                        type:'GET',
                        data:{"json":JSON.stringify(json)},
//                      dataType :'jsonp',
                        success:function(datas){
                            if(datas.Success===true){
                                // setCookie('CustCode',datas.CustCode,720);
                                //setCookie('username',encodeURIComponent(username),720);
                                // setCookie('EmpCode',datas.EmpCode,720);
                                location.href='./list.html';
                            }else{
                                $('.error-tip').html("密码修改不成功，请重试").show().addClass('shake').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
                                    $(this).removeClass('shake');
                                });
                            }
                        },
                        error:function(datas){
                            if(datas.Msg){
                                $('.error-tip').html(datas.Msg).show().addClass('shake').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
                                    $(this).removeClass('shake');
                                });
                            }else{
                                show_error_tip();
                            }
                        }
                    });
                }else{//验证出错
                    $('.error-tip').html(errorMsg).show().addClass('shake').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
                        $(this).removeClass('shake');
                    });
                }
            })
        })
    </script>
</body>
</html>